Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(daml): creation of connector class #3615

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

raynatopedrajeta
Copy link
Contributor

Commit to be reviewed

feat(daml): creation of connector class

Primary Changes
---------------
1. Create a DAML connector class
2. Created OpenAPI endpoints of DAML
3. Created DAML web services for create, exercise and query contracts
4. Create simple IOU Transaction using DAML

Fixes #3489

Pull Request Requirements

  • Rebased onto upstream/main branch and squashed into single commit to help maintainers review it more efficient and to avoid spaghetti git commit graphs that obfuscate which commit did exactly what change, when and, why.
  • Have git sign off at the end of commit message to avoid being marked red. You can add -s flag when using git commit command. You may refer to this link for more information.
  • Follow the Commit Linting specification. You may refer to this link for more information.

Character Limit

  • Pull Request Title and Commit Subject must not exceed 72 characters (including spaces and special characters).
  • Commit Message per line must not exceed 80 characters (including spaces and special characters).

A Must Read for Beginners
For rebasing and squashing, here's a must read guide for beginners.

Copy link
Contributor

@jagpreetsinghsasan jagpreetsinghsasan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please incorporate these changes and then re-request for review (Make sure to squash the commits into a single commit)

"generate-sdk:go": "openapi-generator-cli generate -i ./src/main/json/openapi.json -g go -o ./src/main/go/generated/openapi/go-client/ --git-user-id hyperledger --git-repo-id $(echo $npm_package_name | replace @hyperledger/ \"\" -z)/src/main/go/generated/openapi/go-client --package-name $(echo $npm_package_name | replace @hyperledger/ \"\" -z) --reserved-words-mappings protected=protected --ignore-file-override ../../openapi-generator-ignore",
"generate-sdk:kotlin": "openapi-generator-cli generate -i ./src/main/json/openapi.json -g kotlin -o ./src/main/kotlin/generated/openapi/kotlin-client/ --reserved-words-mappings protected=protected --ignore-file-override ../../openapi-generator-ignore",
"generate-sdk:typescript-axios": "openapi-generator-cli generate -i ./src/main/json/openapi.json -g typescript-axios -o ./src/main/typescript/generated/openapi/typescript-axios/ --ignore-file-override ../../openapi-generator-ignore",
"generate-server": "yarn run --top-level openapi-generator-cli generate -i ./src/main/json/openapi.json -g kotlin-spring -o ./src/main-server/kotlin/gen/kotlin-spring/ -c ./src/main-server/openapi-generator-config.yaml --ignore-file-override ../../openapi-generator-ignore",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do not need this. Please remove this (might got have remained when you copied this from corda connector)

}
},
"operationId": "exerciseChoice",
"summary": "This method creates a simple iou countract",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update the summary and the following description of this path

}
},
"operationId": "queryRawContract",
"summary": "This method queries DAML contracts",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update this, along with the description and mention why is it different from the above query-iou-endpoint method

}
},
"operationId": "getPartiesInvolved",
"summary": "This method queries DAML contracts",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update this to match the referenced path

import type { Server as SecureServer } from "https";
import type { Config as SshConfig } from "node-ssh";
import type { Express } from "express";
// import urlcat from "urlcat";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove all instances of uncommented (unused) code.

try {
if (this.apiUrl === undefined)
throw new InternalServerError("apiUrl option is necessary");
const body = await this.options.connector.createContract(req.body, "testdata123");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we passing testdata123 here? Should this variable be passed from the test case itself if required? (And thus be a part of req.body?)

try {
if (this.apiUrl === undefined)
throw new InternalServerError("apiUrl option is necessary");
const body = await this.options.connector.exerciseContract(req.body, "testdata123");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we passing testdata123 here? Should this variable be passed from the test case itself if required? (And thus be a part of req.body?)

}

async handleRequest(req: Request, res: Response): Promise<void> {
const fnTag = "QueryIOURawEndpointRequest#handleRequest()";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update this to QueryRawIOUEndpoint... to match the api endpoint

}
const createIou = await apiClient.createIou(iouBody)
console.log("STEP 1. Create IOU as Alice result:")
console.log(createIou)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use LoggerProvider class from cactus-common instead

responseForIOUResult = JSON.parse(stringifyIOUPayload)


console.log("STEP 4. Check if transfer is successful by querying as BOB")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rephrase all these statements (along with using LoggerProvider class). Right now it looks like this is the line from where step4 execution starts.

}

public async transact(): Promise<any> {
return null as any;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jagpreetsinghsasan I agree, this looks closer to something application specific instead of belong in the generic framework code. I'm not an expert on DAML/Canton, but maybe we are looking for something like this instead?
https://docs.daml.com/app-dev/grpc/proto-docs.html#submitandwait-method-version-com-daml-ledger-api-v1

Primary Changes
---------------
1. Create a DAML connector class
2. Created OpenAPI endpoints of DAML
3. Created DAML web services for create, exercise and query contracts
4. Create simple IOU Transaction using DAML

Fixes hyperledger-cacti#3489

Signed-off-by: raynato.c.pedrajeta <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat(daml): creation of connector class
3 participants